import {debounce} from './utils';
import BackTop from '../components/content/backtop/BackTop.vue'

export const itemListenerMixin = { 
  data() {
    return {
      itemImgListener: null
    }
  },
  mounted() {
    //1. 图片加载完成的监听事件
    let refresh = debounce(this.$refs.scroll.refresh, 50);
    this.itemImgListener =  () => {
      refresh();
    }
    this.$bus.$on('itemImgLoad', this.itemImgListener)
    // console.log("222");
    
  }
}

export const backTopMixin = {
  components: {
    BackTop,
  },
  data() {
    return {
      isShowBackTop: false
    }
  },
  methods: {
    backTop() {
      this.$refs.scroll.scrollTo(0, 0);
    },
    listenShowBackTop(position) {
      this.isShowBackTop = -position.y > 1000;
    }
  }
}